package com.minelx.sequence.core;

public class Match {
	private Match() {
	}

	public static ReturnMatcher<String, StringScanner> content(String target) {
		return ReturnMatcher.create(
				scanner -> scanner.exists(target),
				scanner -> scanner.nextChars(target.length()));
	}

	public static ReturnMatcher<String, StringScanner> character(char target) {
		return ReturnMatcher.create(
				scanner -> scanner.existsIf(character -> character == target),
				scanner -> String.valueOf(scanner.nextChar())
		);
	}

	public static ReturnMatcher<String, StringScanner> page() {
		return ReturnMatcher.create(
				scanner -> scanner.existsIf(Character::isAlphabetic),
				StringScanner::nextPage);
	}

	public static ReturnMatcher<String, StringScanner> alpha() {
		return ReturnMatcher.create(
				scanner -> scanner.existsIf(Character::isAlphabetic),
				StringScanner::nextAlpha);
	}

	public static ReturnMatcher<String, StringScanner> digit() {
		return ReturnMatcher.create(
				scanner -> scanner.existsIf(Character::isDigit),
				StringScanner::nextDigit);
	}

	public static ReturnMatcher<Character, StringScanner> anAlpha() {
		return ReturnMatcher.create(
				scanner -> scanner.existsIf(Character::isAlphabetic),
				StringScanner::nextChar);
	}

	public static ReturnMatcher<Character, StringScanner> aDigit() {
		return ReturnMatcher.create(
				scanner -> scanner.existsIf(Character::isDigit),
				StringScanner::nextChar);
	}
}
